package com.frx.datastruct.chaptersix;

/**
 * Created by xurenfeng on 2019/2/28.
 */
public class Main {

    public static void main(String[] args){

        BST<Integer> bst = new BST<>();
        int nums[] = {5,3,2,4,6,8};
        for (int i = 0;i<nums.length;i++){
            bst.add(nums[i]);
        }

        System.out.println("二分搜索树的前序遍历结果如下：");
        bst.preOrder();
        System.out.println();
        System.out.println("二分搜索树非递归方式实现的前序遍历结果如下：");
        bst.preOrderNR();
        System.out.println();
        System.out.println("二分搜索树的中序遍历结果如下：");
        bst.inOrder();
        System.out.println();
        System.out.println("后序遍历结果如下：");
        bst.postOrder();
        System.out.println();
        System.out.println("层序遍历结果如下：");
        bst.levelOrder();
        System.out.println();
        System.out.println(bst);
        int[] nums2 = {2,3,1,4,5,6};
        BST<Integer> bst2 = new BST<>();
        for (int i = 0; i<nums2.length;i++){
            bst2.add(nums2[i]);
        }
        System.out.println("Max depth = " + bst2.getMaxDepth());
    }
}
